Skip to content

feat(common): encode the SNARK aggregate signature as bytes in the certificate message - #3437

Merged
jpraynaud merged 5 commits into
mainfrom
jpraynaud/3379-fix-snark-aggregate-signature-encoding
Aug 5, 2026
Merged

feat(common): encode the SNARK aggregate signature as bytes in the certificate message#3437
jpraynaud merged 5 commits into
mainfrom
jpraynaud/3379-fix-snark-aggregate-signature-encoding

Conversation

@jpraynaud

@jpraynaud jpraynaud commented Jul 27, 2026

Copy link
Copy Markdown
Member

Content

This PR includes the encoding of the certificate message aggregate signature by type, so SNARK and IVC proofs use the compact bytes-hex encoding while concatenation proofs remain backward compatible:

  • Encode the certificate message multi_signature field by aggregate signature type: JSON-hex for concatenation proofs (backward compatible with all deployed clients) and bytes-hex for SNARK and IVC proofs.
  • Route the genesis signatures through the native ProtocolKey codec (String::try_from) instead of an explicit bytes-hex call.
  • Keep the certificate hash and chain walking JSON-hex based, so certificate hashes stay byte-identical.

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

Issue(s)

Closes #3379

@jpraynaud jpraynaud self-assigned this Jul 27, 2026
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Test Results

     5 files  ± 0     209 suites  ±0   2h 29m 3s ⏱️ + 1h 29m 10s
 3 374 tests +44   3 374 ✅ +44  0 💤 ±0  0 ❌ ±0 
11 144 runs  +54  11 144 ✅ +54  0 💤 ±0  0 ❌ ±0 

Results for commit 59773cf. ± Comparison against base commit eb74d84.

♻️ This comment has been updated with latest results.

@jpraynaud
jpraynaud temporarily deployed to testing-2-preview July 27, 2026 15:37 — with GitHub Actions Inactive
@jpraynaud
jpraynaud temporarily deployed to testing-preview July 27, 2026 15:37 — with GitHub Actions Inactive
@jpraynaud
jpraynaud force-pushed the jpraynaud/3379-fix-snark-aggregate-signature-encoding branch 2 times, most recently from 897008f to a37adb3 Compare July 28, 2026 15:39
@jpraynaud
jpraynaud requested a review from Copilot July 28, 2026 16:25
@jpraynaud
jpraynaud marked this pull request as ready for review July 28, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates how certificate-related cryptographic payloads are encoded so that SNARK/IVC proofs use a more compact byte-string CBOR representation (and bytes-hex on the wire where applicable), while keeping concatenation proofs backward compatible via JSON-hex encoding. This aligns certificate message/record serialization with the ProtocolKey codec to ensure consistent encoding decisions by aggregate signature type.

Changes:

  • Emit CBOR byte strings for proof byte vectors by using serde_bytes for SNARK/IVC proof fields and the aggregate signature CBOR envelope.
  • Route certificate message and DB record encoding through String::try_from(&ProtocolKey<...>) to centralize encoding decisions in the ProtocolKeyCodec.
  • Introduce a custom ProtocolKeyCodec for AggregateSignature that encodes concatenation as JSON-hex and (when enabled) SNARK/IVC as bytes-hex.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
mithril-stm/src/protocol/aggregate_signature/signature.rs Encodes CBOR envelope proof_bytes as a CBOR byte string and updates golden CBOR fixtures accordingly.
mithril-stm/src/proof_system/halo2_snark/proof.rs Serializes SNARK circuit_proof with serde_bytes for compact CBOR bytes.
mithril-stm/src/circuits/halo2_ivc/types.rs Serializes IVC proof byte wrapper with serde_bytes for compact CBOR bytes.
mithril-stm/Cargo.toml Adds serde_bytes dependency (and ignores it for cargo-machete).
mithril-common/src/messages/certificate.rs Uses ProtocolKey codec (String::try_from) for certificate crypto fields; adds tests for multi-signature encoding by type.
mithril-common/src/crypto_helper/types/wrappers.rs Implements custom ProtocolKeyCodec for AggregateSignature to encode by signature type (JSON-hex vs bytes-hex).
mithril-aggregator/src/database/record/certificate.rs Stores certificate signatures/keys via ProtocolKey codec (String::try_from) and adds a test for SNARK multi-signature storage encoding.
Cargo.lock Locks the new serde_bytes dependency.

@jpraynaud
jpraynaud temporarily deployed to testing-2-preview July 28, 2026 16:33 — with GitHub Actions Inactive
@jpraynaud
jpraynaud temporarily deployed to testing-preview July 28, 2026 16:33 — with GitHub Actions Inactive

@damrobi damrobi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@turmelclem turmelclem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Encode the multi-signature by type through the ProtocolKey codec: JSON-hex for concatenation (backward compatible), bytes-hex for SNARK and IVC proofs.
…codec

The record now encodes the certificate crypto fields via the ProtocolKey codec, so the served SNARK multi-signature is bytes-hex instead of JSON-hex.
Serialize the aggregate signature and proof byte vectors as byte strings instead of arrays of integers, which halves their encoded size at each nesting level.
* mithril-aggregator from `0.9.19` to `0.9.20`
* mithril-common from `0.7.15` to `0.7.16`
* mithril-stm from `0.12.1` to `0.12.2`
@jpraynaud
jpraynaud force-pushed the jpraynaud/3379-fix-snark-aggregate-signature-encoding branch from a37adb3 to 59773cf Compare August 4, 2026 16:18
@jpraynaud
jpraynaud temporarily deployed to testing-preview August 4, 2026 17:12 — with GitHub Actions Inactive
@jpraynaud
jpraynaud temporarily deployed to testing-2-preview August 4, 2026 17:12 — with GitHub Actions Inactive
@jpraynaud
jpraynaud merged commit 5470a67 into main Aug 5, 2026
50 checks passed
@jpraynaud
jpraynaud deleted the jpraynaud/3379-fix-snark-aggregate-signature-encoding branch August 5, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use bytes encoding for aggregate signature in certificate message

5 participants